package com.baoteng.rbspy.interceptor;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.Response;

public class HttpLoginInterceptor  implements Interceptor {

	private final Logger logger = LoggerFactory.getLogger(HttpLoginInterceptor.class);
	
	@Override
	public Response intercept(Chain chain) throws IOException {
		Request request = chain.request();
		Builder builder= request.newBuilder()
				.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)")
//				.addHeader("Cookie", "JSESSIONID=TnFvZLzTq1jGtVhdlmDpVTc9LtFrWW56rSJPyv5GkGh8BPGPtSbQ!-1444111664; BOCINS_prpall_Cookie=8lBrZLyJsdRWDbV205xpKDyN2ZPLJLVpR615ShV215RzT4lxnF9J!-834241103")
				.addHeader("Content-Type", "application/x-www-form-urlencoded")
				.addHeader("Cache-Control", "no-cache")
				.addHeader("DNT","1");
//				.addHeader("prpall", "1293013067")
//				.addHeader("JSESSIONID", "rxV8ZLrSTKDLpn70pnGN8V1DddfhttqD5mmLghp2RmvFBnmRNmMN!259042951");
		logger.info(" add cookie.");
		return chain.proceed(builder.build());
	}
}
